package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class MainActivity98 extends AppCompatActivity {

    private static final String TAG = "MainActivity98";

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity98.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main98 );

        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put( "int", 1 );
            jsonObject.put( "string", "this a message" );
            JSONArray array = new JSONArray( "[\n"
                + "        { \"name\":\"Google\", \"info\":[ \"Android\", \"Google 搜索\", \"Google 翻译\" ] },\n"
                + "        { \"name\":\"Runoob\", \"info\":[ \"菜鸟教程\", \"菜鸟工具\", \"菜鸟微信\" ] },\n"
                + "        { \"name\":\"Taobao\", \"info\":[ \"淘宝\", \"网购\" ] }\n"
                + "    ]" );
            jsonObject.put( "array", array );

            Log.i( TAG, "onCreate: " + jsonObject.toString() );
        } catch ( JSONException e ) {
            e.printStackTrace();
        }

        try {
            JSONArray jsonArray = new JSONArray( "[1234567890]" );
            jsonObject.put( "single", jsonArray );
            Log.i( TAG, "onCreate: " + jsonObject.toString() );
        } catch ( JSONException e ) {
            e.printStackTrace();
        }
    }
}